﻿Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class NodeItemDisplayControl

    Private m_Project As Project

    Public ReadOnly Property Project() As Project
        Get
            Return m_Project
        End Get
    End Property

    Private m_Node As Node

    Public ReadOnly Property Node() As Node
        Get
            Return m_Node
        End Get
    End Property

    Public Sub SetValues(ByVal Project As Project, ByVal Node As Node)
        m_Project = Project
        m_Node = Node
        Refresh()
    End Sub


    Public Overrides Sub Refresh()
        Me.ux_PanelNodes.Controls.Clear()
        '--------------------------------
        If Not m_Node Is Nothing Then

            Me.ux_LabelItterationTitle.Text = Node.Name
            Me.ux_StickyDisplayControl.SetValues(Project, Node)

            If Node.HasChildNodes Then

                Dim tbl As New TableLayoutPanel
                ux_PanelNodes.Controls.Add(tbl)
                tbl.BackColor = Color.Lime
                tbl.Dock = DockStyle.Fill
                tbl.ColumnCount = Node.ChildNodes.Count

                For c As Integer = 0 To Node.ChildNodes.Count - 1
                    Dim newNodeItemDisplay As New NodeItemDisplayControl
                    newNodeItemDisplay.Dock = DockStyle.Fill
                    tbl.Controls.Add(newNodeItemDisplay, c, 0)
                    newNodeItemDisplay.SetValues(Project, Node.ChildNodes(c))
                Next

            Else
                Dim CellPos = Me.ux_TableLayoutPanel.GetCellPosition(Me.ux_PanelNodes)
                Me.ux_PanelNodes.Visible = False
                Me.ux_TableLayoutPanel.SetRowSpan(ux_StickyDisplayControl, 2)
            End If
        End If
        MyBase.Refresh()
    End Sub

End Class
